package org.jivesoftware.smackx.forward;

import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.provider.PacketExtensionProvider;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.packet.DelayInfo;
import org.jivesoftware.smackx.provider.DelayInfoProvider;
import org.xmlpull.v1.XmlPullParser;

public class Forwarded
  implements PacketExtension
{
  public static final String NAMESPACE = "urn:xmpp:forward:0";
  public static final String ELEMENT_NAME = "forwarded";
  private DelayInfo delay;
  private Packet forwardedPacket;

  public Forwarded(DelayInfo paramDelayInfo, Packet paramPacket)
  {
    this.delay = paramDelayInfo;
    this.forwardedPacket = paramPacket;
  }

  public String getElementName()
  {
    return "forwarded";
  }

  public String getNamespace()
  {
    return "urn:xmpp:forward:0";
  }

  public String toXML()
  {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append("\">");
    if (this.delay != null)
      localStringBuilder.append(this.delay.toXML());
    localStringBuilder.append(this.forwardedPacket.toXML());
    localStringBuilder.append("</").append(getElementName()).append(">");
    return localStringBuilder.toString();
  }

  public Packet getForwardedPacket()
  {
    return this.forwardedPacket;
  }

  public DelayInfo getDelayInfo()
  {
    return this.delay;
  }

  public static class Provider
    implements PacketExtensionProvider
  {
    DelayInfoProvider dip = new DelayInfoProvider();

    public PacketExtension parseExtension(XmlPullParser paramXmlPullParser)
      throws Exception
    {
      DelayInfo localDelayInfo = null;
      Packet localPacket = null;
      int i = 0;
      while (i == 0)
      {
        int j = paramXmlPullParser.next();
        if (j == 2)
        {
          if (paramXmlPullParser.getName().equals("delay"))
            localDelayInfo = (DelayInfo)this.dip.parseExtension(paramXmlPullParser);
          else if (paramXmlPullParser.getName().equals("message"))
            localPacket = PacketParserUtils.parseMessage(paramXmlPullParser);
          else
            throw new Exception("Unsupported forwarded packet type: " + paramXmlPullParser.getName());
        }
        else if ((j == 3) && (paramXmlPullParser.getName().equals("forwarded")))
          i = 1;
      }
      if (localPacket == null)
        throw new Exception("forwarded extension must contain a packet");
      return new Forwarded(localDelayInfo, localPacket);
    }
  }
}

/* Location:           D:\hygieia\userclient\common\libs\easemobchat_2.1.8.jar
 * Qualified Name:     org.jivesoftware.smackx.forward.Forwarded
 * JD-Core Version:    0.6.1
 */